package pluginUtils.geneticAlgorithms;

import java.util.ArrayList;

public class Genome {
	private static boolean bound=false;
	private static int X,Y; 
	private ArrayList<Cercle> adn=new ArrayList<Cercle>();
 
	
	public int getLength(){return adn.size();}
	
	public static void setBounds(int x,int y) throws AllreadyboundedADNException{
		if(bound) throw new AllreadyboundedADNException();
		bound=true; 
		Genome.X=x; 
		Genome.Y=y; 
		}
	
	private Genome(){}
	
	public static Genome copy(Genome u){
		Genome v=new Genome(); 
		v.adn=new ArrayList<Cercle>(u.adn); 
		return v; 
	}
	
	public static Genome createVoidGenome() throws UnboundedADNException{
		if(!bound) throw new UnboundedADNException();
		Genome hector=new Genome();
		return hector; 
	}
	
	public void add(int index,Cercle c){
		this.adn.add(index,c); 
	}
	
	public void add(Cercle c){ this.adn.add(c);}
	
	public static Genome createGenome(int length) throws UnboundedADNException{
		if(!bound) throw new UnboundedADNException();
		Genome hector=new Genome(); 
		for(int i=0;i<length;i++)
			hector.adn.add(new Cercle(Genome.X,Genome.Y)); 
		return hector; 
	}

	public Cercle get(int i) {
		return this.adn.get(i); 
	}

	public static int getX() {	
		return X;
	}
	
	public static int getY() {
		return Y;
	}
	
	public String toString(){
		String s=""; 
		for(int i=0;i<this.adn.size();i++)
			s+="\t\t\n"+this.adn.get(i);
		return s; 
	}
}
